/**
* Copyright @ 2023 iAuto (Shanghai) Co., Ltd.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are NOT permitted except as agreed by
* iAuto (Shanghai) Co., Ltd.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/


import React from 'react';
import {
    Drawer,
    Descriptions,
    Divider,
} from 'antd';
import { servelistChildProps } from '@/types/soaManage'
const labelStyle = {
    width: 140
}
const label2Style = {
    width: 110
}
export default (props: servelistChildProps | any) => {
    const {
        itemRow,
        itemRowDrawer,
        setItemRowDrawer
    } = props
    return (
        <Drawer
            key={232}
            title={itemRow?.sName}
            placement="right"
            width={'30%'}
            onClose={() => {
                setItemRowDrawer(false);
            }}
            visible={itemRowDrawer}
        >
            <Descriptions title="" column={1}>
                <Descriptions.Item labelStyle={labelStyle} label="服务接口元素名称">{itemRow.mName}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="服务接口元素描述">{itemRow.description}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="接口主要版本">{itemRow.majorVersion}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="接口次要版本">{itemRow.minorVersion}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="服务接口元素类型">{itemRow.methodType}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="服务接口元素标识符">{itemRow.functionId}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="事件组">{itemRow.eventGroupName}</Descriptions.Item>
                <Descriptions.Item labelStyle={labelStyle} label="传输层协议">{itemRow.l4Protocol}</Descriptions.Item>
            </Descriptions>
            <Divider />
            {itemRow?.params?.map((item: any) => {
                return (
                    <div key={item?.name + item?.paramId}>
                        <Descriptions title="" column={1}>
                            <Descriptions.Item labelStyle={label2Style} label="参数名称">{item.name}</Descriptions.Item>
                            <Descriptions.Item labelStyle={label2Style} label="参数数据类型">{item.referType}</Descriptions.Item>
                            <Descriptions.Item labelStyle={label2Style} label="参数描述">{item.description}</Descriptions.Item>
                            <Descriptions.Item labelStyle={label2Style} label="参数发送方向">{item.direction}</Descriptions.Item>
                        </Descriptions>
                        <Divider />
                    </div>
                );
            })}
        </Drawer>
    )
}